package com.xtck.ha.system.api.factory;


/**
 * 数据分析服务降级处理
 *
 * @author zhouss
 */
import com.xtck.ha.common.core.domain.R;
import com.xtck.ha.common.domain.system.api.TblAnomalyWarnings;
import com.xtck.ha.common.domain.system.api.TblTelemetryTaskInfo;
import com.xtck.ha.common.domain.system.api.analysis.*;
import com.xtck.ha.system.api.RemoteDataAnalysisService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteDataAnalysisFallbackFactory implements FallbackFactory<RemoteDataAnalysisService> {
    @Override
    public RemoteDataAnalysisService create(Throwable throwable) {
        return new RemoteDataAnalysisService()
        {
            @Override
            public R<Boolean> add(TblAnomalyWarnings tblAnomalyWarnings, String source)
            {
                return R.fail("新增异常告警数据失败:" + throwable.getMessage());
            }

            @Override
            public R run(TblTelemetryTaskInfo taskInfo, String source)
            {
                return R.fail("处理数据:" + throwable.getMessage());
            }

            @Override
            public R addSatellite(TblSatelliteNeo tblSatelliteNeo) {
                return R.fail("新增卫星:" + throwable.getMessage());
            }

            @Override
            public R addDevice(TblDeviceNeo tblSatelliteNeo) {
                return R.fail("新增设备:" + throwable.getMessage());
            }

            @Override
            public R addParam(TblTmParamNeo tblSatelliteNeo) {
                return R.fail("新增参数:" + throwable.getMessage());
            }

            @Override
            public R addResolver(TblResolverNeo tblSatelliteNeo) {
                return R.fail("新增预案:" + throwable.getMessage());
            }

            @Override
            public R addSubSystem(TblSubsystemNeo tblSubsystemNeo) {
                return R.fail("新增分系统:" + throwable.getMessage());
            }

            @Override
            public R updateSatellite(TblSatelliteNeo tblSatelliteNeo) {
                return R.fail("修改卫星:" + throwable.getMessage());
            }

            @Override
            public R updateDevice(TblDeviceNeo tblSatelliteNeo) {
                return R.fail("修改设备:" + throwable.getMessage());
            }

            @Override
            public R updateParam(TblTmParamNeo tblSatelliteNeo) {
                return R.fail("修改参数:" + throwable.getMessage());
            }

            @Override
            public R updateResolver(TblResolverNeo tblSatelliteNeo) {
                return R.fail("修改预案:" + throwable.getMessage());
            }

            @Override
            public R updateSubSystem(TblSubsystemNeo tblSubsystemNeo) {
                return R.fail("修改分系统:" + throwable.getMessage());
            }

            @Override
            public R generate(String source) {
                return R.fail("生成结果失败:" + throwable.getMessage());
            }
        };
    }
}
